#include <iostream>

using namespace std;

int NumberOf1InBinary1(int n){
    int count = 0;
    unsigned int flag = 1;

    while ( flag ){
        if ( n & flag ){
            count ++;
        }
        flag = flag << 1;
    }
    return count;
}

int NumberOf1InBinary2(int n ){
    int count = 0;
    while ( n ){
        count ++;
        n = (n-1) & n ;
    }
    return count;
}

int main(void){
    cout << "NumberOf1InBinary1: " << NumberOf1InBinary1(0xFFFFFFFF) << endl;
    cout << "NumberOf1InBinary2: " << NumberOf1InBinary2(0xFFFFFFFF) << endl;
    return 0;
}